#pragma once
#include <jthread.h>
#include <dsound.h>
#include "MutexBuffer.h"

namespace ipsound {

class PlayIPSound : public JThread
{
public:
	PlayIPSound( MutexBuffer* buffer, HWND window );
	void* Thread();
	~PlayIPSound();
private:
	void InitWaveFormat();
	void PutDataInSoundBuffer( const void* data, const size_t& size );
private:
	MutexBuffer* buffer;
	WAVEFORMATEX wfx;
	DSBUFFERDESC SoundBufDesc;
	LPDIRECTSOUNDBUFFER8 soundBuf8;
	unsigned short channelsNum, bitsPerSample;
	unsigned long samplesPerSec, soundBufOffset;
};

}
